home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 January
/
Macworld (1998-01).dmg
/
Shareware World
/
Comms & Internet
/
HTML mode 2.0 etc.
/
html32.tcl
< prev
next >
Wrap
Text File
|
1997-09-22
|
12KB
|
296 lines
## -*-Tcl-*-
# ###################################################################
# HTML mode - tools for editing HTML documents
#
# FILE: "html32.tcl"
# created: 97-01-25 23.46.46
# last update: 97-09-21 17.44.20
# Author: Johan Linde
# E-mail: <jl@theophys.kth.se>
# www: <http://bach.theophys.kth.se/~jl/Alpha.html>
#
# Version: 2.0
#
# Copyright 1996, 1997 by Johan Linde
#
# This software may be used freely, and distributed freely, as long as the
# receiver is not obligated in any way by receiving it.
#
# If you make improvements to this file, please share them!
#
# ###################################################################
##
proc html32.tcl {} {}
#
# htmlElemAttrRequired: the per-element lists of all required attributes
# htmlElemAttrOptional: the per-element lists of all optional attributes
# htmlElemAttrChoices: element-specific attribute completions
# htmlElemAttrNumber: the per-element list of attributes which are numbers.
# htmlElemEventHandler: the per-element list of JavaScript's event handlers.
# htmlElemAttrUsed: the per-element list of elements asked for in the status bar.
#
# htmlElemAttrOptional has to be defined for every element for everything
# to work.
set htmlElemAttrOptional3(HTML) {}
set htmlElemAttrOptional3(HEAD) {}
set htmlElemAttrOptional3(TITLE) {}
set htmlElemAttrOptional3(BODY) {BACKGROUND= BGCOLOR= TEXT= LINK= VLINK= ALINK=}
htmlSetAttrUsed 3 BODY {BACKGROUND= BGCOLOR= TEXT= LINK= VLINK=}
set htmlElemAttrOptional3(STYLE) {TYPE=}
set htmlElemAttrOptional3(SPAN) {}
htmlSetAttrUsed 3 SPAN {CLASS= ID= STYLE=}
set htmlElemAttrOptional3(H1) {ALIGN= }
set htmlElemAttrChoices3(H1) {ALIGN=CENTER ALIGN=RIGHT ALIGN=LEFT}
htmlSetAttrUsed 3 H1 {ALIGN=}
set htmlElemAttrOptional3(H2) {ALIGN= }
set htmlElemAttrChoices3(H2) {ALIGN=CENTER ALIGN=RIGHT ALIGN=LEFT}
htmlSetAttrUsed 3 H2 {ALIGN=}
set htmlElemAttrOptional3(H3) {ALIGN= }
set htmlElemAttrChoices3(H3) {ALIGN=CENTER ALIGN=RIGHT ALIGN=LEFT}
htmlSetAttrUsed 3 H3 {ALIGN=}
set htmlElemAttrOptional3(H4) {ALIGN= }
set htmlElemAttrChoices3(H4) {ALIGN=CENTER ALIGN=RIGHT ALIGN=LEFT}
htmlSetAttrUsed 3 H4 {ALIGN=}
set htmlElemAttrOptional3(H5) {ALIGN= }
set htmlElemAttrChoices3(H5) {ALIGN=CENTER ALIGN=RIGHT ALIGN=LEFT}
htmlSetAttrUsed 3 H5 {ALIGN=}
set htmlElemAttrOptional3(H6) {ALIGN= }
set htmlElemAttrChoices3(H6) {ALIGN=CENTER ALIGN=RIGHT ALIGN=LEFT}
htmlSetAttrUsed 3 H6 {ALIGN=}
set htmlElemAttrOptional3(P) {ALIGN= }
set htmlElemAttrChoices3(P) {ALIGN=CENTER ALIGN=RIGHT ALIGN=LEFT}
htmlSetAttrUsed 3 P {ALIGN=}
set htmlElemAttrOptional3(BLOCKQUOTE) {}
set htmlElemAttrOptional3(DIV) {ALIGN= }
set htmlElemAttrChoices3(DIV) {ALIGN=CENTER ALIGN=RIGHT ALIGN=LEFT}
htmlSetAttrUsed 3 DIV {ALIGN=}
set htmlElemAttrOptional3(ADDRESS) {}
set htmlElemAttrOptional3(CENTER) {}
set htmlElemAttrOptional3(PRE) {WIDTH= }
set htmlElemAttrNumber3(PRE) {WIDTH=1:i:n}
set htmlElemAttrOptional3(BR) {CLEAR= }
set htmlElemAttrChoices3(BR) {CLEAR=ALL CLEAR=LEFT CLEAR=RIGHT CLEAR=NONE}
set htmlElemAttrOptional3(HR) {ALIGN= SIZE= WIDTH= NOSHADE}
set htmlElemAttrChoices3(HR) {ALIGN=LEFT ALIGN=RIGHT ALIGN=CENTER}
set htmlElemAttrNumber3(HR) {SIZE=1:i:n WIDTH=1:i:%}
set htmlElemAttrOptional3(FONT) {SIZE= COLOR=}
set htmlElemAttrNumber3(FONT) {SIZE=1:7:n}
htmlSetAttrUsed 3 FONT {SIZE=}
set htmlElemAttrRequired3(BASEFONT) {SIZE=}
set htmlElemAttrOptional3(BASEFONT) {}
set htmlElemAttrNumber3(BASEFONT) {SIZE=1:7:n}
set htmlElemAttrOptional3(B) {}
set htmlElemAttrOptional3(I) {}
set htmlElemAttrOptional3(STRIKE) {}
set htmlElemAttrOptional3(U) {}
set htmlElemAttrOptional3(SUB) {}
set htmlElemAttrOptional3(SUP) {}
set htmlElemAttrOptional3(BIG) {}
set htmlElemAttrOptional3(SMALL) {}
set htmlElemAttrOptional3(EM) {}
set htmlElemAttrOptional3(STRONG) {}
set htmlElemAttrOptional3(DFN) {}
set htmlElemAttrOptional3(CODE) {}
set htmlElemAttrOptional3(VAR) {}
set htmlElemAttrOptional3(CITE) {}
set htmlElemAttrOptional3(KBD) {}
set htmlElemAttrOptional3(TT) {}
set htmlElemAttrOptional3(SAMP) {}
set htmlElemAttrOptional3(A) {HREF= NAME= REL= REV= TITLE= }
htmlSetAttrUsed 3 A {HREF= NAME=}
set htmlElemAttrRequired3(IMG) {SRC=}
set htmlElemAttrOptional3(IMG) {WIDTH= HEIGHT= BORDER=
ALIGN= ALT= HSPACE= VSPACE= USEMAP= ISMAP}
set htmlElemAttrChoices3(IMG) {ALIGN=TOP ALIGN=MIDDLE ALIGN=BOTTOM
ALIGN=LEFT ALIGN=RIGHT}
set htmlElemAttrNumber3(IMG) {BORDER=0:i:n WIDTH=1:i:n HEIGHT=1:i:n
HSPACE=0:i:n VSPACE=0:i:n}
htmlSetAttrUsed 3 IMG {SRC= WIDTH= HEIGHT= ALIGN= ALT=}
set htmlElemAttrOptional3(UL) {TYPE= COMPACT}
set htmlElemAttrChoices3(UL) {TYPE=DISC TYPE=CIRCLE TYPE=SQUARE}
set htmlElemAttrOptional3([list LI IN UL]) {TYPE=}
set htmlElemAttrChoices3([list LI IN UL]) {TYPE=DISC TYPE=CIRCLE TYPE=SQUARE}
set htmlElemAttrOptional3(OL) {TYPE= START= COMPACT}
set htmlElemAttrChoices3(OL) {TYPE=A TYPE=a TYPE=I TYPE=i TYPE=1}
set htmlElemAttrNumber3(OL) {START=1:i:n}
set htmlElemAttrOptional3([list LI IN OL]) {TYPE= VALUE=}
set htmlElemAttrNumber3([list LI IN OL]) {VALUE=1:i:n}
set htmlElemAttrChoices3([list LI IN OL]) {TYPE=A TYPE=a TYPE=I TYPE=i TYPE=1}
set htmlElemAttrOptional3(DIR) {COMPACT}
set htmlElemAttrOptional3(MENU) {COMPACT}
set htmlElemAttrOptional3(LI) {}
set htmlElemAttrOptional3(DL) {COMPACT}
set htmlElemAttrOptional3(DT) {}
set htmlElemAttrOptional3(DD) {}
set htmlElemAttrOptional3(FORM) {ACTION= METHOD= ENCTYPE= }
set htmlElemAttrChoices3(FORM) {METHOD=POST METHOD=GET}
htmlSetAttrUsed 3 FORM {ACTION= METHOD= }
set htmlElemAttrRequired3(TEXT) {NAME=}
set htmlElemAttrOptional3(TEXT) {VALUE= SIZE= MAXLENGTH=}
set htmlElemAttrNumber3(TEXT) {SIZE=1:i:n MAXLENGTH=1:i:n}
htmlSetAttrUsed 3 TEXT {NAME= VALUE= SIZE= MAXLENGTH=}
set htmlElemAttrRequired3(CHECKBOX) {NAME= VALUE=}
set htmlElemAttrOptional3(CHECKBOX) {CHECKED}
htmlSetAttrUsed 3 CHECKBOX {NAME= VALUE= CHECKED}
set htmlElemAttrRequired3(RADIO) {NAME= VALUE=}
set htmlElemAttrOptional3(RADIO) {CHECKED}
htmlSetAttrUsed 3 RADIO {NAME= VALUE= CHECKED}
set htmlElemAttrOptional3(SUBMIT) {NAME= VALUE=}
htmlSetAttrUsed 3 SUBMIT {VALUE= }
set htmlElemAttrOptional3(RESET) {VALUE= }
htmlSetAttrUsed 3 RESET {VALUE= }
set htmlElemAttrRequired3(PASSWORD) {NAME= }
set htmlElemAttrOptional3(PASSWORD) {VALUE= SIZE= MAXLENGTH=}
set htmlElemAttrNumber3(PASSWORD) {SIZE=1:i:n MAXLENGTH=1:i:n}
htmlSetAttrUsed 3 PASSWORD {NAME= VALUE= SIZE= MAXLENGTH=}
set htmlElemAttrRequired3(HIDDEN) {NAME= VALUE=}
set htmlElemAttrOptional3(HIDDEN) {}
set htmlElemAttrRequired3(IMAGE) {NAME= SRC=}
set htmlElemAttrOptional3(IMAGE) {ALIGN=}
set htmlElemAttrChoices3(IMAGE) {ALIGN=TOP ALIGN=MIDDLE ALIGN=BOTTOM
ALIGN=LEFT ALIGN=RIGHT}
set htmlElemAttrRequired3(FILE) {NAME= }
set htmlElemAttrOptional3(FILE) {SIZE= MAXLENGTH=}
set htmlElemAttrNumber3(FILE) {SIZE=1:i:n MAXLENGTH=1:i:n}
set htmlElemAttrRequired3(SELECT) {NAME= }
set htmlElemAttrOptional3(SELECT) {SIZE= MULTIPLE}
set htmlElemAttrNumber3(SELECT) {SIZE=1:i:n}
htmlSetAttrUsed 3 SELECT {NAME= SIZE= MULTIPLE}
set htmlElemAttrOptional3(OPTION) {VALUE= SELECTED}
htmlSetAttrUsed 3 OPTION {SELECTED}
set htmlElemAttrRequired3(TEXTAREA) {NAME= ROWS= COLS=}
set htmlElemAttrOptional3(TEXTAREA) {}
set htmlElemAttrNumber3(TEXTAREA) {ROWS=1:i:n COLS=1:i:n}
set htmlElemAttrOptional3(TABLE) {BORDER= CELLSPACING= CELLPADDING= WIDTH=
ALIGN=}
set htmlElemAttrChoices3(TABLE) {ALIGN=LEFT ALIGN=CENTER ALIGN=RIGHT}
set htmlElemAttrNumber3(TABLE) {BORDER=0:i:n CELLSPACING=0:i:n
CELLPADDING=0:i:n WIDTH=1:i:%}
htmlSetAttrUsed 3 TABLE {BORDER= CELLSPACING= CELLPADDING=}
set htmlElemAttrOptional3(TD) {ALIGN= VALIGN= COLSPAN= ROWSPAN= WIDTH= HEIGHT= NOWRAP}
set htmlElemAttrChoices3(TD) {ALIGN=CENTER ALIGN=RIGHT ALIGN=LEFT
VALIGN=BOTTOM VALIGN=MIDDLE VALIGN=TOP }
set htmlElemAttrNumber3(TD) {COLSPAN=1:i:n ROWSPAN=1:i:n WIDTH=1:i:n HEIGHT=1:i:n}
htmlSetAttrUsed 3 TD {ALIGN= VALIGN= COLSPAN= ROWSPAN= NOWRAP}
set htmlElemAttrOptional3(TH) {ALIGN= VALIGN= COLSPAN= ROWSPAN= WIDTH= HEIGHT= NOWRAP}
set htmlElemAttrChoices3(TH) {ALIGN=LEFT ALIGN=CENTER ALIGN=RIGHT
VALIGN=BOTTOM VALIGN=MIDDLE VALIGN=TOP }
set htmlElemAttrNumber3(TH) {COLSPAN=1:i:n ROWSPAN=1:i:n WIDTH=1:i:n HEIGHT=1:i:n}
htmlSetAttrUsed 3 TH {ALIGN= VALIGN= COLSPAN= ROWSPAN= NOWRAP }
set htmlElemAttrOptional3(TR) {ALIGN= VALIGN= }
set htmlElemAttrChoices3(TR) {ALIGN=CENTER ALIGN=RIGHT ALIGN=LEFT
VALIGN=BOTTOM VALIGN=MIDDLE VALIGN=TOP }
htmlSetAttrUsed 3 TR {ALIGN= VALIGN=}
set htmlElemAttrOptional3(CAPTION) {ALIGN=}
set htmlElemAttrChoices3(CAPTION) {ALIGN=BOTTOM ALIGN=TOP }
htmlSetAttrUsed 3 CAPTION {ALIGN=}
set htmlElemAttrRequired3(MAP) {NAME=}
set htmlElemAttrOptional3(MAP) {}
set htmlElemAttrRequired3(AREA) {COORDS= ALT=}
set htmlElemAttrOptional3(AREA) {SHAPE= HREF= NOHREF}
set htmlElemAttrChoices3(AREA) {SHAPE=RECT SHAPE=CIRCLE SHAPE=POLY}
htmlSetAttrUsed 3 AREA {SHAPE= COORDS= HREF= NOHREF}
set htmlElemAttrRequired3(APPLET) {CODE= WIDTH= HEIGHT=}
set htmlElemAttrOptional3(APPLET) {CODEBASE= HSPACE= VSPACE= ALIGN= NAME= ALT=}
set htmlElemAttrChoices3(APPLET) {ALIGN=TOP ALIGN=MIDDLE ALIGN=BOTTOM
ALIGN=LEFT ALIGN=RIGHT}
set htmlElemAttrNumber3(APPLET) {VSPACE=0:i:n HSPACE=0:i:n WIDTH=1:i:n
HEIGHT=1:i:n}
htmlSetAttrUsed 3 APPLET {CODE= WIDTH= HEIGHT= CODEBASE= ALIGN= }
set htmlElemAttrRequired3(PARAM) {NAME= VALUE=}
set htmlElemAttrOptional3(PARAM) {}
set htmlElemAttrRequired3(BASE) {HREF= }
set htmlElemAttrOptional3(BASE) {}
set htmlElemAttrOptional3(ISINDEX) {PROMPT=}
set htmlElemAttrOptional3(LINK) {HREF= REL= REV= TITLE= TYPE=}
htmlSetAttrUsed 3 LINK {HREF=}
set htmlElemAttrRequired3(META) {CONTENT=}
set htmlElemAttrOptional3(META) {NAME= HTTP-EQUIV=}
# Add style sheet attrs, CLASS, ID, STYLE.
set tmpNoStyle {BASE BASEFONT HEAD HTML META PARAM STYLE TITLE}
foreach tmp [array names htmlElemAttrOptional3] {
if {[lsearch -exact $tmpNoStyle $tmp] < 0} {
lappend htmlElemAttrOptional3($tmp) CLASS= ID= STYLE=
}
}
unset tmp tmpNoStyle
proc htmlCheckConfig3 {} {
upvar mayContain mayContain empty empty closingOptional closingOptional form form
set headmisc {SCRIPT STYLE META LINK}
set headContent {TITLE ISINDEX BASE}
set heading {H1 H2 H3 H4 H5 H6}
set lists {UL OL DIR MENU}
set preformatted {PRE}
set font {TT I B U STRIKE BIG SMALL SUB SUP}
set phrase {EM STRONG DFN CODE SAMP KBD VAR CITE}
set special {A IMG APPLET FONT BASEFONT BR SCRIPT MAP}
set form {INPUT SELECT TEXTAREA}
set text [concat text $font $phrase $special $form]
set block [concat P $lists $preformatted DL DIV CENTER BLOCKQUOTE FORM ISINDEX HR TABLE]
set flow [concat $text $block]
set bodyContent [concat $heading $text $block ADDRESS]
# Empty elements
set empty {BASEFONT BR AREA LINK IMG PARAM HR INPUT ISINDEX BASE META}
# Define what each element mayContain contain
foreach i [concat $font $phrase FONT A P $heading PRE DT CAPTION] {
set mayContain($i) $text
}
set mayContain(A) [lreplace $mayContain(A) [set where [lsearch -exact $mayContain(A) A]] $where]
set preExclusion {IMG BIG SMALL SUB SUP FONT}
foreach i $preExclusion {
set where [lsearch -exact $mayContain(PRE) $i]
set mayContain(PRE) [lreplace $mayContain(PRE) $where $where]
}
foreach i {BODY DIV CENTER BLOCKQUOTE FORM TH TD} {
set mayContain($i) $bodyContent
}
set mayContain(FORM) [lreplace $mayContain(FORM) [set where [lsearch -exact $mayContain(FORM) FORM]] $where]
set mayContain(ADDRESS) [concat $text P]
set mayContain(MAP) AREA
set mayContain(APPLET) [concat $text PARAM]
set mayContain(DL) {DT DD}
set mayContain(DD) $flow
set mayContain(LI) $flow
foreach i $lists {
set mayContain($i) LI
}
set mayContain(SELECT) OPTION
set mayContain(OPTION) text
set mayContain(TEXTAREA) text
set mayContain(TABLE) {CAPTION TR}
set mayContain(TR) {TD TH}
set mayContain(HEAD) [concat $headContent $headmisc]
set mayContain(SCRIPT) text
set mayContain(STYLE) text
set mayContain(TITLE) text
set mayContain(HTML) {HEAD BODY}
# Dummy tag to start with.
set mayContain(WINDOW) HTML
# These have an optional closing tag.
set closingOptional {P DT DD LI OPTION TR TD TH HEAD BODY HTML WINDOW}
}